/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package its.mx.dsw2.view;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import mx.its.dsw2.Bl.UserBLLocal;
import mx.itsc.ds2.model.User;

/**
 *
 * @author Martinez
 */
@ManagedBean
@RequestScoped
public class AccesBean {
    @EJB
    private UserBLLocal userBL;
    
    private String user;
    private String password;

    
    //------------------Getter y Setter-----------------------//
    
    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    
    //-------------------------------------------------//

    
    //----------------------Constructores-----------------------//
    public AccesBean() {
    }
    //----------------------------------------------------------//
    
    //-----------------------Actions-----------------------------//
        public String procesarAction(){
        for (User usu : userBL.findAll()) {
            if (user.equalsIgnoreCase(usu.getAccesId()) && password.equalsIgnoreCase(usu.getPassword())) {
            return "PrincipalMenu";
            }
        }   
        return "Login";
    }
    
    //-----------------------------------------------------------//
}
